<include file="common:head" />

<div class="box">
		<div class="server_info">
			<!-- 店鋪標題 -->
			<div class="server_name" style="text-align: center;">
				單次服務
			</div>
			<!-- 服務詳情 -->
			<div class="server_detail">
				<div class="server_detail_left">
					<div class="txt">
						<foreach name="serverPriceData" item='v'>
	                		<div class="once_server">
                				<span style="padding-left:5%;">
										<input type="checkbox" name="onceServerName" value="{$v.id}" style="width:50px;height:50px; ">
	                					【<span style="color:#ff8800;">{$v.server_name}</span>】
	                				<span style="padding-right:15%;float: right;">
										<switch name="userCarType">
			                                <case value="1">{$v.five_price}</case>
			                                <case value="2">{$v.seven_price}</case>
			                                <case value="3">{$v.other_price}</case>
			                                <default>{$v.five_price}
			                            </switch>元
	                				</span>
                				</span>
	                		</div>
                		</foreach>
					</div>
				</div>
			</div>
			<!-- 服務詳情 -->
		</div>

	<notempty name="UsermonthData">
		<div class="server_info">
			<!-- 標題 -->
			<div class="server_name" style="text-align: center;">
				月卡服務
			</div>
			<!-- 服務詳情 -->
			<div class="server_detail">
				<div class="server_detail_left">
					<div class="txt">
						<input type="hidden" id="month_card_id" value="{$UsermonthData['id']}">
						<foreach name="UsermonthData['use_month_card']" item='v'>
	                		<div class="month_server">
	                			<span style="padding-left: 5%;">
									<input type="checkbox" name="monthServerName" value="{$v.id}" style="width:50px;height:50px; ">
		                			【<span style="color:#ff8800">{$v.server_name}</span>】
		                			<span style="padding-right: 10%;float: right;">
			                			剩餘次數：<span style="color:#ff8800;">{$v.server_times}</span>
		                			</span>
		                		</span>
	                		</div>
                		</foreach>
					</div>
				</div>
			</div>
			<!-- 服務詳情 -->
		</div>
	</notempty>
	<!-- 溫馨提示 -->
	<!-- <div class="tips">
		<img src="__PRIVATE__/Images/horn.png"/>
		【温馨提醒】{$list.tips}
	</div> -->
</div>

<div class="bottom1"  style="height:8%;">
	<div class="go_pay" style="padding:4%;" onclick="javascript:selOnceCard('{$address_id}');">
		前去下单
	</div>
</div>

<script type="text/javascript">
$('title').html('銘聯洗車');
$('.header .title').html('選擇服務');
$('.header .left').html('<img src="__PRIVATE__/images/left.png" style="width:55%"/>');
$('.header .right').html('');
$('.header .left').click(function(){
	//跳转到--【下单页面】
	window.location.href = "{:U(MODULE_NAME.'/index/gopay',array('id'=>$address_id))}";
});

function selOnceCard(id){
	var flag  		 = false;
	var once_server  = '';
	var month_server = $('#month_card_id').val()+','; //记录当前使用的月卡id
	$.each($("input[name=onceServerName]:checked"),function(){
		once_server += $(this).val()+ ',' ;
    });
    $.each($("input[name=monthServerName]"),function(){
    	if ($(this).prop('checked')) {
	    	var times = ($(this).next().next().find('span').text())-1;
			month_server += $(this).val()+'|'+$(this).next().text()+'|'+times+'|'+'checked'+ ',' ;
			flag = true;
    	}else{
    		var times = $(this).next().next().find('span').text();
			month_server += $(this).val()+'|'+$(this).next().text()+'|'+times+'|'+'notchecked'+ ',' ;
    	}
    });
    //判断 单次和月卡服务
    if (once_server) {
    	console.dir(once_server);
	    $.cookie('once_server',once_server, { expires: 7, path: '/' }); //洗车点id
	    if(month_server && flag){
	    	console.dir(month_server);
		    $.cookie('month_server',month_server, { expires: 7, path: '/' }); //洗车点id
	    }
    }else if(month_server && flag){
    	console.dir(month_server);
	    $.cookie('month_server',month_server, { expires: 7, path: '/' }); //洗车点id
    }else{
    	layer.open({
		    content: '請勾選服務'
		    ,skin: 'msg'
		    ,style: 'width: 30%; height:5%;padding:20px;font-size:3rem;'
		    ,time: 2 //2秒后自动关闭
		});
    	return false;
    }
    //跳转到确认订单页面--confirm
	window.location.href = "/index/confirm/id/"+id;
}
</script>
